package CA;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

import junit.framework.TestCase;


public class CrashSuper_Test extends TestCase {
//	private final String MainExaminLocation = "C:/SignatureOutput/noscan/UnitTests/";
	private final String MainExaminLocation = System.getProperty("user.dir") + "/UnitTestData/";
	
	
	protected void setUp() throws Exception {
		super.setUp();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	
	// Ensure that the file list is retrieved properly
	public void testGetFileList()
	{
		String compareFile = MainExaminLocation+"FileScan/";
		CrashSuper cs = new CrashSuper();
		assertEquals(cs.getFileList(compareFile).size(),4);
		
		
	}
	
	
	// test computeValuesEntireString
	public void testComputeValuesEntireString(){

		String compareFile = MainExaminLocation+"CrashSuper/";
		CrashSuper cs = new CrashSuper();
		Helper h = new Helper();
		
		List<FileInfo> fileList = new ArrayList<FileInfo>();

		File f1=new File(compareFile+"CrashSuperSub/file1.txt"); 
		File f2=new File(compareFile+"CrashSuperSub/file2.txt"); 
		File f3=new File(compareFile+"CrashSuperSub/file3.txt"); 
		fileList=cs.getFileList(compareFile);
		FileInfo folderToExamine = fileList.get(h.getArrayIndex(fileList, "CrashSuperSub"));
	
		
		// All of the values should be 0 when starting
//		assertEquals(folderToExamine.getTotalStringGenericDistance(),0);
//		assertEquals(folderToExamine.getTotalStringJaro(),0.0);
//		assertEquals(folderToExamine.getTotalStringJaroWinkler(),0.0);
//		assertEquals(folderToExamine.getTotalStringLCS(),0);
//		assertEquals(folderToExamine.getTotalStringMongeElkan(),0.0);
//		assertEquals(folderToExamine.getTotalStringNW(),0.0);
//		assertEquals(folderToExamine.getTotalStringScaledLevenstein(),0.0);
//		assertEquals(folderToExamine.getTotalStringSmithWaterman(),0.0);
		
		// Now perform the computations on the file
//		cs.computeValuesEntireString(f1, f2, folderToExamine);
	
		// The values should have changed
//		assertEquals(folderToExamine.getTotalStringGenericDistance(),8);
//		assertEquals(folderToExamine.getTotalStringJaro(),.94);
//		assertEquals(folderToExamine.getTotalStringJaroWinkler(),.96);
//		assertEquals(folderToExamine.getTotalStringLCS(),37);
	//	assertEquals(folderToExamine.getTotalStringMongeElkan(),1.0);
//		assertEquals(folderToExamine.getTotalStringNW(),66.0);
//		assertEquals(folderToExamine.getTotalStringScaledLevenstein(),.82);
//		assertEquals(folderToExamine.getTotalStringSmithWaterman(),74.0);
		
		// Now compare another folder
	//	cs.computeValuesEntireString(f2, f3, folderToExamine);
//		assertEquals(folderToExamine.getTotalStringGenericDistance(),41);
//		assertEquals(folderToExamine.getTotalStringJaro(),.56);
//		assertEquals(folderToExamine.getTotalStringJaroWinkler(),.56);
//		assertEquals(folderToExamine.getTotalStringLCS(),44);
//		assertEquals(folderToExamine.getTotalStringMongeElkan(),.55);
//		assertEquals(folderToExamine.getTotalStringNW(),63.0);
//		assertEquals(folderToExamine.getTotalStringScaledLevenstein(),.31);
//		assertEquals(folderToExamine.getTotalStringSmithWaterman(),17.0);
	
		
	}
	
	
	//ComputeValuesLineByLine
	public void testComputeValuesLineByLine()
	{
		String compareFile = MainExaminLocation+"CrashSuper/";
		CrashSuper cs = new CrashSuper();
		Helper h = new Helper();
		
		List<FileInfo> fileList = new ArrayList<FileInfo>();
		File f1=new File(compareFile+"CrashSuperSub/file1.txt"); 
		File f2=new File(compareFile+"CrashSuperSub/file2.txt"); 
		File f3=new File(compareFile+"CrashSuperSub/file3.txt"); 
		
		
		fileList=cs.getFileList(compareFile);
		FileInfo folderToExamine = fileList.get(h.getArrayIndex(fileList, "CrashSuperSub"));
	
		
		// All of the values should be 0 when starting
//		assertEquals(folderToExamine.getGenericStringDistanceTotal(),0);
//		assertEquals(folderToExamine.getJaro(),0.0);
//		assertEquals(folderToExamine.getJaroWinkler(),0.0);
//		assertEquals(folderToExamine.getLCS(),0);
//		assertEquals(folderToExamine.getMongeElkan(),0.0);
		
		/*
		 * Finish this
		assertEquals(folderToExamine.get(),0.0);
		assertEquals(folderToExamine.getTotalStringScaledLevenstein(),0.0);
		assertEquals(folderToExamine.getTotalStringSmithWaterman(),0.0);
		*/
		
		
		
		
	}
	
	
	
	public void testAvoidDuplicateValues()
	{
		
	}
	
	
	
	
	
	
	
	
}
